package cn.rui.pojo.exam;

import cn.rui.pojo.User;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 徽州大都督
 * @date 2021/6/28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user_answer")
@ApiModel(description = "学生答题类", value = "学生答题类")
public class UserAnswer implements Serializable {

    @TableId(type = IdType.AUTO)
    private Long id;

    //学生id
    private Integer userId;

    @TableField(exist = false)
    private User user;

    //试卷id
    private Long paperId;

    //单选题答案
    private String radioAnswer;

    //多选题答案
    private String multiAnswer;

    //判断题答案
    private String judgeAnswer;

    //简答题答案
    private String shortAnswer;

    //主观题得分(单选、多选、判断)
    private Integer subjectiveScore=0;

    //简答题得分
    private Integer objectiveScore=0;

    //总分
    private Integer totalScore;

    //是否需要老师评分（1已评分、2无需评分、3未评分）
    private Integer isMarkSub;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @TableLogic
    private Integer delFlag;

    private String objScore;

    @Ignore
    public Integer getTotalScore() {
        return this.subjectiveScore+this.objectiveScore;
    }
}
